package workers;

import domain.ConcurrentContainerInterface;

/**
 * @author igordv
 *
 */
public class NegativeProducer extends AbstractWorker {
	protected int m_amount;
	/**
	 * @param container
	 */
	public NegativeProducer(ConcurrentContainerInterface<Integer> container, int amount) {
		super(container);
		m_amount = amount;
	}
	public NegativeProducer(ConcurrentContainerInterface<Integer> stack, int amount, int delay) {
		super(stack, delay);
		m_amount = amount;
	}
	/* (non-Javadoc)
	 * @see AbstractWorker#description()
	 */
	@Override
	public String description() {
		return "NegativeProducer";
	}

	/* (non-Javadoc)
	 * @see AbstractWorker#run()
	 */
	@Override
	public void threadLogic() {
		for (int i = 0; i < m_amount; i++) {
			m_container.insert(new Integer(-1*i));	
			try {
				Thread.sleep((long) (Math.random()*m_delayTimeInMillis));
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
